package org.example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Edge {
    int from;
    int to;
    int cost;
    Edge(int from, int to, int cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        List<Edge> grid = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            int v = scanner.nextInt();
            grid.add(new Edge(s, t, v));
        }
        int src = scanner.nextInt();
        int dst = scanner.nextInt();
        int k = scanner.nextInt();

        int[] minDist = new int[N + 1];
        Arrays.fill(minDist, Integer.MAX_VALUE);
        minDist[src] = 0;
        int[] prevMinDist;
        for (int i = 0; i <= k; i++) {
            prevMinDist = minDist.clone();
            for (Edge e : grid) {
                if (prevMinDist[e.from] < Integer.MAX_VALUE && minDist[e.to] > prevMinDist[e.from] + e.cost) {
                    minDist[e.to] = prevMinDist[e.from] + e.cost;
                }
            }
        }

        if (minDist[dst] < Integer.MAX_VALUE) {
            System.out.println(minDist[dst]);
        } else {
            System.out.println("unreachable");
        }
    }
}